package org.dtrd.modules.patient.entity.bean;

import cn.hutool.core.date.DateUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.dtrd.common.util.DateUtils;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.patient.entity.po.DtrdEntRdPatient;

/**
 * @author xiao
 */
@Data
@ApiModel(value = "患者信息")
public class PatientInfo {

    @ApiModelProperty("患者id")
    private Integer dataId;

    @ApiModelProperty("手机号码")
    private String patientsMobile;

    @ApiModelProperty(value = "是否更新糖尿病信息", notes = "默认false", example = "false")
    private Boolean updateDiabetes = false;

    /**
     * 唯一标识
     */
    private String patientsUuid;

    /**
     * 患者姓名
     */
    @ApiModelProperty("患者姓名")
    private String patientsName;

    /**
     * 用户昵称
     */
    private String patientsNickname;

    @ApiModelProperty("出生日期")
    private String patientsBirthday;

    @ApiModelProperty("年龄")
    private Integer age;

    /**
     * 性别
     */
    @ApiModelProperty(value = "患者性别", notes = "1-男,2-女")
    private Integer patientsSex;

    /**
     * 身份证号
     */
    private String patientsIdCard;

    /**
     * 身高
     */
    @ApiModelProperty("患者身高")
    private Integer patientsHeight;

    /**
     * 体重
     */
    @ApiModelProperty("患者体重")
    private Float patientsWeight;

    /**
     * 头像图片地址
     */
    @ApiModelProperty("患者头像")
    private String patientsImg;

    /**
     * 糖尿病类型
     */
    @ApiModelProperty("糖尿病类型")
    private Integer patientsDiabetisType;
    @ApiModelProperty("糖尿病类型名称")
    private String patientsDiabetisTypeName;

    @ApiModelProperty("确诊日期")
    private String patientsConfirmedDate;

    /**
     * 起病方式
     */
    private String patientsModeOnset;

    private String patientsModeOnsetName;

    /**
     * 起病症状
     */
    private String patientsSymptoms;

    private String patientsSymptomsName;

    /**
     * 医保类型
     */
    private String patientsMedicalInsurance;
    private String patientsMedicalInsuranceName;

    /**
     * 诊断结果
     */
    private String patientsDiagnostic;
    private String patientsDiagnosticName;

    /**
     * 患者位置
     */
    private String patientsLocation;

    /**
     * 类型
     */
    private Integer patientsType;

    /**
     * 患者名称首字母大写
     */
    private String patientsInitial;

    @ApiModelProperty("注册时间")
    private String createTime;

    private String updateTime;

    /**
     * 企业微信客户Id
     */
    private String patientsQywxExternalUserid;

    /**
     * 企业微信成员id
     */
    private String patientsQywxUserid;

    /**
     * 患者主诉
     */
    private String patientsDesc;

    /**
     * 复诊状态
     */
    private Integer status;

    /**
     * 小程序微信openID
     */
    private String wxOpenid;

    private String wxOaOpenid;

    private String wxUnionid;

    private String kingdeeCustomerId;
    private String doctorName;

    @ApiModelProperty(value = "当前服务名称", example = "在管、续管等")
    private String serviceName;

    @ApiModelProperty(value = "打卡天数")
    private Integer checkinDays;

    @ApiModelProperty(value = "请求源")
    private String clientsn;

    public PatientInfo parseFromPO(DtrdEntRdPatient po) {
        dataId = po.getDataId();
        patientsName = po.getPatientsName();
        patientsMobile = po.getPatientsMobile();
        patientsNickname = po.getPatientsNickname();
        if (po.getPatientsBirthday() != null) {
            patientsBirthday = DateUtils.formatDate(po.getPatientsBirthday());
            age = DateUtil.age(po.getPatientsBirthday(),null);
        }
        patientsDesc = po.getPatientsDescription();
        patientsIdCard = po.getPatientsIdCard();
        patientsHeight = po.getPatientsHeight();
        patientsSymptoms = po.getPatientsSymptoms();
        patientsWeight = po.getPatientsWeight();
        patientsImg = po.getPatientsImg();
        patientsSex = po.getPatientsSex();
        patientsDiabetisType = po.getPatientsDiabetisType();
        patientsDiabetisTypeName = Constant.DiabetesType.valueOf(po.getPatientsDiabetisType()).getName();
        patientsModeOnset = po.getPatientsModeOnset();
        patientsDiagnostic = po.getPatientsDiagnostic();
        if (po.getPatientsConfirmedDate() != null) {
            patientsConfirmedDate = DateUtils.formatDate(po.getPatientsConfirmedDate());
        }
        patientsMedicalInsurance = po.getPatientsMedicalInsurance();
        wxOpenid = po.getWxOpenid();
        wxOaOpenid = po.getWxOaOpenid();
        wxUnionid = po.getWxUnionid();
        return this;
    }

    @Override
    public String toString() {
        return "PatientInfo{" +
                "dataId=" + dataId +
                ", patientsMobile='" + patientsMobile + '\'' +
                ", updateDiabetes=" + updateDiabetes +
                ", patientsName='" + patientsName + '\'' +
                ", patientsBirthday='" + patientsBirthday + '\'' +
                ", patientsSex=" + patientsSex +
                ", patientsHeight=" + patientsHeight +
                ", patientsWeight=" + patientsWeight +
                ", patientsDiabetisType=" + patientsDiabetisType +
                ", wxOpenid='" + wxOpenid + '\'' +
                ", wxUnionid='" + wxUnionid + '\'' +
                '}';
    }

}